Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): Add time synchronization check to setupOS #3433

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

andrewbattat
Copy link
Member

NODE-1504

  • Force the RTC to keep time in UTC
  • Add a check for if system clock is synchronized

@andrewbattat andrewbattat self-assigned this Jan 13, 2025
@github-actions github-actions bot added the feat label Jan 13, 2025
Comment on lines +16 to +37
function check_ntp() {
echo "* Checking Chrony status..."

systemctl is-active --quiet chrony
log_and_halt_installation_on_error "$?" "Chrony service not running or not active."

retries=0
max_retries=30
while [ "$(timedatectl show -p NTPSynchronized --value)" != "yes" ]; do
if [ $retries -ge $max_retries ]; then
local service_logs=$(journalctl -u chrony.service --no-pager)
local log_message="System clock is not synchronized.\n\nChrony service logs:\n${service_logs}"
log_and_halt_installation_on_error 1 "${log_message}"
fi

echo "* Chrony not yet synchronized. Waiting 2 seconds before retry..."
sleep 2
((retries++))
done

echo "* Chrony is running and time is in sync."
}
Copy link
Member Author

@andrewbattat andrewbattat Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reran installation a number of times on bare metal, and here are the number of chrony retries each installation took:

  • 0
  • 12 (24 seconds)
  • 12 (24 seconds)
  • 12 (24 seconds)
  • 0
  • 12 (24 seconds)
  • 12 (24 seconds)
  • 11 (22 seconds)

Is this acceptable to us? We could just roll this out and if it ever causes a false negative, roll it back. I'm not sure this is worth more of a time investment.

@andrewbattat andrewbattat marked this pull request as ready for review January 14, 2025 20:10
@andrewbattat andrewbattat requested a review from a team as a code owner January 14, 2025 20:10
@github-actions github-actions bot added the @node label Jan 14, 2025
Copy link
Member

@Bownairo Bownairo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one quick change, but otherwise looks OK to me

Comment on lines +41 to +42
set_hwclock_utc
check_ntp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to sync ntp first, then update the hardware clock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants